package com.xteam.xnetworkdisk.sys.controller;

import com.xteam.xnetworkdisk.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("redis")
public class RedisController {

    @Autowired
    private RedisUtils redisUtils;

    /**
     * 写入Redis
     * @return
     */
    @GetMapping("/write")
    public String write() {
        redisUtils.write("woou", "Hello from Redis");
        return "Value written to Redis";
    }

    /**
     * 读取Redis
     * @return
     */

    @GetMapping("/read")
    public String read() {
        Object value = redisUtils.readTemplate("woou");
        return "Value from Redis: " + value;
    }
}
